<template>
	<view class="team">
		<view style="height: 100upx;" class="flex0 bB1 bT1">
			<view style="width: 240upx;" class="C666 fs22">名称</view>
			<view class="">
				<input v-model="storeName" class="C666 fs22" placeholder="未填写默认为您的昵称" type="text" value="" />
			</view>
		</view>	
		<view style="height: 260upx;" class="flex0 bB1 ">
			<view style="width: 200upx;" class="C666 fs22">图标</view>
			<view class="">
				<image style="width: 160upx;height: 160upx;" @click="upload(1)" :src="img1 ? img1 : `${picUrl}/w/pt.png`" mode=""></image>
				<view class="">请上传正方形的图片（效果最佳）</view>
			</view>
		</view>	
		<view style="height: 260upx;" class="flex0 bB1 ">
			<view style="width: 200upx;" class="C666 fs22">店招</view>
			<view class="">
				<image style="width: 160upx;height: 160upx;" @click="upload(2)" :src="img2 ? img2 : `${picUrl}/w/pt.png`" mode=""></image>
				<view class="">请上传750*400的图片（效果最佳）</view>
			</view>
		</view>	
		<view style="height: 260upx;" class="flex0 bB1 ">
			<view style="width: 200upx;" class="C666 fs22">名片</view>
			<view class="">
				<image style="width: 160upx;height: 160upx;" @click="upload(3)" :src="img3 ? img3 : `${picUrl}/w/pt.png`" mode=""></image>
				<view class="">请上传750*720的图片（效果最佳）</view>
			</view>
		</view>	
		<view style="height: 300upx;" class="flex0 bB1 ">
			<view style="width: 200upx;" class="C666 fs22">简介</view>
			<view style="height: 250upx;border: 1upx solid #F8F8F8;" class="">				   
				<textarea v-model="text"  style="padding: 20upx;box-sizing: border-box;" value="" placeholder="小店简介，分享你的小店" />
			</view>
		</view>	
		<!-- <view style="height: 100upx;display: none;justify-content: space-between;align-content: center;" class="bB1">
			<view style="width: 200upx;line-height: 100upx;" class="C666 fs22">我的位置</view>
			<view style="width: 72pux;height: 40upx;transform: scale(0.6);margin-top: 15upx;" class="fs27">
				<switch color="#4cd964" @change="switch2Change" />
			</view>
		</view>	 -->
		
		<view @click="ok()" class="sunmitBtn Cfff fs18">
			保存设置
		</view>
	</view>
	
</template>

<script>
	const requImg = require("@/common/api_sign/requImg.js")
	export default {
		data() {
			return {
				storeName:"",
				img1:"",
				img2:"",
				img3:"",
				isData:true,
				Imgdata:{},
				ImgInfo1:"",
				ImgInfo2:"",
				ImgInfo3:"",
				image:"",
				text:"",
				imgUrl:"",
				imgFlag:false,
				addBtn:true,
				imageList:[],
				imgUrl2:"",
				imgFlag2:false,
				addBtn2:true,
				imageList2:[],
				lis:[0,1,2,3,4],
				active1:0,
				active2flag:2,
				bottomBtn:[
					{"name":"首页","img1":"../../static/images/home_bottom11.png","img2":"../../static/images/home_bottom12.png","toUrl":"../home/index"},
					{"name":"分类","img1":"../../static/images/home_bottom21.png","img2":"../../static/images/home_bottom22.png","toUrl":"../sort/sortPage"},
					{"name":"分销","img1":"../../static/images/home_bottom31.png","img2":"../../static/images/home_bottom32.png","toUrl":"../distribution/list"},
					{"name":"购物车","img1":"../../static/images/home_bottom41.png","img2":"../../static/images/home_bottom42.png","toUrl":"../car/shopCar"},
					{"name":"会员中心","img1":"../../static/images/home_bottom51.png","img2":"../../static/images/home_bottom52.png","toUrl":"/pages/home/Personal_Center"}
				]
			}
		},
		onShow() {
			
		},
		onLoad() {
			this.getLis()
		},
		methods: {
			ok(){
				this.$util.request({//保存设置
					url: '/mobile/index.php?act=distribution&op=submitShopInfo',
					method: 'post',
					data: {
						"name":this.storeName,
						"logo":this.ImgInfo1,
						"img":this.ImgInfo2,
						share_img:this.ImgInfo3,
						"desc":this.text						
					},
				}).then((res)=> {
						if(res.error_code == 0){
							uni.showToast({
								title:res.message
							})
							setTimeout(()=>{
								uni.navigateTo({
									url:"/member/distribution/index"
								})
							},1500)
						}else{
							uni.showToast({
								title:res.message
							})
						}
				})
			},
			
			upload(i){
				let that = this;
				if(that.isData){
					uni.chooseImage({//图片选择上传
					 count: 1,
					 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					 sourceType: ['album','camera'], //从相册选择
					 success: (res)=> {
					const tempFilePaths = res.tempFilePaths;
					let  data = requImg.request("index.php?act=upload&op=uploadFile&buss_type="+that.$uploadType.uploadtype007);
					 var uper = uni.uploadFile({
					  // 需要上传的地址
					  url:this.$apiurl+"index.php?act=upload&op=uploadFile",
					  // filePath  需要上传的文件
					  filePath: tempFilePaths[0],
					  name: 'file',
					  //  header: {
						 //  'content-type': 'text/html; charset=UTF-8' 
					  // },
					  formData: {
						buss_type:data.buss_type,
					    key:data.key,
						
						api_sign:data.api_sign, 
						comefrom:data.comefrom,
						api_time:data.api_time,
						// api_member_id:data.api_member_id,
						// api_member_name:data.api_member_name,
					 },
					  success(res1) {
						  let ImgInfo=JSON.parse(res1.data)
						  if(ImgInfo.error_code==0){
							  if(i==1){
								that.img1=ImgInfo.datas.file_url;
								that.ImgInfo1=ImgInfo.datas.file_path;
							  }else if(i==2){
								that.img2=ImgInfo.datas.file_url;
								that.ImgInfo2=ImgInfo.datas.file_path;
							  }else if(i==3){
								that.img3=ImgInfo.datas.file_url;
								that.ImgInfo3=ImgInfo.datas.file_path;
							  }
						}else{
							uni.showToast({
								title:ImgInfo.message,
								icon:"none"
							})
						}
					},
					fail(e){
						uni.showToast({
							title:e,
							icon:"none"
						})
					}
				  })				
					
					 }
					});
				}else{
					uni.showToast({
						title:"图片正在上传中",
						icon:"loading"
					})
				}
				  
			},
			switch2Change: function (e) {
				console.log('switch2 发生 change 事件，携带值为', e.target.value)
			},
			
			chooseImage: async function() {
                uni.chooseImage({
                    sourceType:['camera', 'album'],
                    // #ifdef MP-WEIXIN
                    sizeType: ['compressed', 'original'],
                    // #endif
                    count: 1,
                    success: (res) => {
						this.imageList=res.tempFilePaths
                        const tempFilePaths = res.tempFilePaths;//                      
						this.imgUrl=res.tempFilePaths[0]
						this.imgFlag=true
						this.addBtn=false
                    }
                })
            },
  			previewImage: function(e) {
                var current = e
//               var current = e.target.dataset.src
                uni.previewImage({
                    current: current,
                    urls: this.imageList
                })
            },
			chooseImage2: async function() {
                uni.chooseImage({
                    sourceType:['camera', 'album'],
                    // #ifdef MP-WEIXIN
                    sizeType: ['compressed', 'original'],
                    // #endif
                    count: 1,
                    success: (res) => {
						this.imageList2=res.tempFilePaths
                        const tempFilePaths = res.tempFilePaths;//                      
						this.imgUrl2=res.tempFilePaths[0]
						this.imgFlag2=true
						this.addBtn2=false
                    }
                })
            },
  			previewImage2: function(e) {
                var current = e
//               var current = e.target.dataset.src
                uni.previewImage({
                    current: current,
                    urls: this.imageList2
                })
            },
			switch1Change: function (e) {
				console.log('switch1 发生 change 事件，携带值为', e.target.value)
			},
			getLis(){//获取页面数据
				this.$util.request({
					url: '/mobile/index.php?act=distribution&op=getShopInfo',
					method: 'get',
					data: {
				
					},
				}).then((res)=> {						
					this.storeName=res.datas.shopInfo.name
					this.img1=res.datas.shopInfo.logo_url
					this.img2=res.datas.shopInfo.img_url
					this.img3=res.datas.shopInfo.share_url
					this.text=res.datas.shopInfo.desc
					this.ImgInfo1=res.datas.shopInfo.logo_path
					this.ImgInfo2=res.datas.shopInfo.img_path
					this.ImgInfo3=res.datas.shopInfo.share_path
					

				})
			}
					
		}
	}
</script>

<style>	
	.status_bar {
	    height: var(--status-bar-height);  
	    width: 100%;  
	    background-color: #FFFFFF;
	}  
	.top_view {  
	    height: var(--status-bar-height);  
	    width: 100%;  
	    position: fixed;  
	    background-color: #FFFFFF;  
	    top: 0;  
	    z-index: 999;  
	}
	.lh20{
		line-height: 20upx;
		height: 20upx;
	}
	.lh25{
		line-height: 25upx;
	}
	.lh30{
		line-height: 30upx;
	}
	.lh35{
		line-height: 35upx;
	}
	.lh40{
		line-height: 40upx;
	}
	.lh45{
		line-height: 45upx;
	}
	.lh50{
		line-height: 50upx;
	}
	.lh100{
		line-height: 100upx;
	}
	.C000{
		color: #000000;
	}
	.Ce13d97{
		color: #ff4300;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.Cc06{
		color: #ff4300;
	}
	.mt55mb30{
		margin-top: 55upx;
		margin-bottom: 30upx;
	}
	.Cfff{
		color: #FFFFFF;
	}

	.flex{		
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-content: space-between;
	}
	.flex0{
		display: flex;
	}
	.paddingL20{
		padding-left: 20upx;
	}
	.C999{
		color:#999 ;
	}
	.Cff0101{
		color:#ff0101 ;
	}
	.Cc00251{
		color: #c00251;
	}
	.strick{
		text-decoration: line-through;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.line1{
		width: 430upx;
	}
	.hide{
		display: none;
	}
	.marginB20{
		margin-bottom: 20upx;
	}
	
	.twoline{
	   overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.pl20{
		padding-left: 20upx;
	}
	.positionT{
		position: relative;
		top: 50upx;
	}
	.paddingB15{
		padding-bottom: 15upx;
	}
	.borderB{
		border-bottom: 1px solid #f4f4f6;
	}
	.borderT{
		border-top: 1px solid #f4f4f6;
	}
	.gl{
		position: absolute;
		right: 30upx;
	}
	.pr30{
		padding-right: 30upx;
	}
	.C333{
		color: #333333;
	}
	.C666{
		color: #666666;
	}
	.Cf00{
		color: #ff0000;
	}
	
	.bold{
		font-weight: bold;
	}
	.C1d1d1d{
		color:#1d1d1d ;
	}
	.fl{
		float: left;
	}
	.fr{
		float: right;
	}
	.tac{
		text-align: center;
	}
	.Ce5258e{
		color: #e5258e;
	}
	.Cccc{
		color: #CCCCCC;
	}
	uni-page-body {
		background-color: #FFFFFF;
	}
	.bB1{
		border-bottom: 1upx solid #f0f0f0;
	}
	.bT1{
		border-top: 1upx solid #f0f0f0;
	}
	.fs30{
		/* font-size: 30upx */
		font-size: 45upx
	}
	.fs26{
		font-size:39upx
		/* font-size: 26upx */
	}
	.fs12{
		font-size: 18upx
		/* font-size: 12upx */
	}
	.fs16{
		font-size: 24upx
		/* font-size: 16upx */
	}
	.fs14{
		font-size: 21upx
		/* font-size: 14upx */
	}
	.fs15{
		font-size: 22.5upx
		/* font-size: 15upx */
	}
	.fs27{
		font-size: 40.5upx
		/* font-size: 27upx */
	}
	.fs18{
		font-size: 27upx
		/* font-size: 18upx */
	}
	.fs28{
		font-size: 42upx
		/* font-size: 28upx */
	}
	.fs10{
		font-size: 15upx
		/* font-size: 10upx */
	}
	.fs30{
		font-size: 45upx
		/* font-size: 28upx */
	}
	.fs24{
		font-size: 36upx
		/* font-size: 24upx */
	}
	.fs20{
		font-size:30upx
		/* font-size: 20upx */
	}
	.fs22{
		font-size:33upx
		/* font-size: 22upx */
	}
	.fs21{
		font-size: 31.5upx
		/* font-size: 21upx */
	}
	
	.bottom{
		box-sizing: border-box;
		padding: 0 10upx;
		background-color: #FFFFFF;
		position: fixed;
		z-index: 99999999999;
		left: 0;
		bottom: 0;
		height: 98upx;
		width: 100%;
		box-shadow: 0upx -1upx 10upx rgba(0,0,0,0.8);
		display: flex;
		flex-direction: row;
		justify-content: space-around;
	}
	.bottom view{
		font-size: 27upx;
		color: #666;
		text-align: center;
	}
	.bottom view.active2{
		color: #ff4300;
	}
	.bottom image{
		position: relative;
		top: 15upx;
		width: 33upx;
		height: 33upx;
	}
	.title2{
		margin-top: 76upx;
		margin-bottom: 0upx;
		height: 35px;
		padding-left: 20upx
	}
	.oneLine{
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}
	.Ce5007e{
		color: #e5007e;
	}
	.team{
		padding: 0 30upx;
		background-color: #FFFFFF;		
	}
	
	.sunmitBtn{
		background: linear-gradient(to right,#ff4300,#db1060,#c10451);
		width: 668upx;
		height: 72upx;
		line-height: 72upx;
		/* margin: 283upx auto 100upx; */
		text-align: center;
	}
</style>
